<template>
    <div>
        <el-button @click="getHello2">测试getHello 函数</el-button>
        <el-button @click="postHello">测试 post 函数</el-button>
        <p>request type is {{this.reqType}} </p>
        <p>req response is {{text}}</p>
    </div>

</template>

<script>
    import api from "@/api/testAxiosApi"

    export default {
        name: "ApiDemo",
        data: function () {
            return {
                reqType: '',
                text: ''
            }
        }, methods: {
            getHello2() {
                console.log("hello world:" + this.testHello);
                console.log("testAxiosApi :" + api)
                this.reqType = 'get'
                api.testHello('hello=1').then((res) => {
                    this.text = res.data;
                });
            },
            postHello() {
                this.reqType = 'post'
                const para = {a: 1};
                api.postHello(para).then((res) => {
                    this.text = res.data;
                });
            }
        }

    }
</script>

<style scoped>

</style>